package com.usian.behavior.controller;

import com.usian.behavior.service.BehaviorEntryService;
import com.usian.model.behavior.pojos.ApBehaviorEntry;
import com.usian.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/behavior")
public class BehaviorEntryController {
    @Autowired
    private BehaviorEntryService behaviorEntryService;

    @PostMapping("/save")
    public ResponseResult saveBehavior(@RequestBody ApBehaviorEntry apBehaviorEntry) {
        return behaviorEntryService.saveBehavior(apBehaviorEntry);
    }

    @PostMapping("/findByUserId")
    public ApBehaviorEntry findByUserId(@RequestParam Integer userId) {
        if (userId == null) return null;
        return behaviorEntryService.findByUserIdOrEquipmentId(userId);
    }
}